package com.levy.utils;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;

import java.io.IOException;

/**
 * Created by 郭利伟 on 2017.09.06.
 */
public class HttpUtil2 {

    public static void main(String[] args) throws IOException {
        String path = "http://www.baidu.com";
        HttpClient client = new HttpClient();
        PostMethod post = new PostMethod(path);
        client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "utf-8");
        NameValuePair simcard1 = new NameValuePair("param","levy");
        post.setRequestBody(new NameValuePair[] { simcard1});
        client.executeMethod(post);
        String result = new String(post.getResponseBody(),"utf-8");
        System.out.println(result);
    }
}
